package ace.module.sms.sdk.core.feign.impl;

import ace.cmp.core.model.R;
import ace.cmp.openfeign.security.oauth2.core.config.FeignInternalServerOauth2SecurityConfig;
import ace.module.common.api.annotation.ApiRemoteProxyPriority;
import ace.module.sms.api.model.input.SendTemplateInput;
import ace.module.sms.sdk.core.constant.SdkConstant;
import ace.module.sms.sdk.core.feign.SmsFeignApi;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 短信.
 *
 * @author caspar
 */
@FeignClient(
    name = "${spring.cloud.openfeign.client.smsFeign.name:" + SdkConstant.FEIGN_SERVICE_NAME + "}",
    contextId = "smsFeign",
    path = SmsFeign.PATH,
    configuration = FeignInternalServerOauth2SecurityConfig.class,
    primary = false
)
@ApiRemoteProxyPriority
public interface SmsFeign extends SmsFeignApi {

  String PATH = "${spring.cloud.openfeign.client.smsFeign.path:/sms/rpc}";

  @PostMapping(path = "/send")
  R<Void> send(
      @Valid @NotNull @RequestParam("smsAppId") Long smsAppId,
      @Valid @NotBlank @RequestParam("phoneNumber") String phoneNumber,
      @Valid @NotBlank @RequestParam("content") String content);

  @PostMapping(path = "/send-template")
  R<Void> sendTemplate(@Valid @NotNull @RequestBody SendTemplateInput input);

  @PostMapping(path = "/send-verify-code")
  R<Void> sendVerifyCode(
      @Valid @NotNull @RequestParam("smsAppId") Long smsAppId,
      @Valid @NotBlank @RequestParam("phoneNumber") String phoneNumber,
      @Valid @NotBlank @RequestParam("code") String code);
}
